package uno.rocc.common.util;

import lombok.Builder;
import lombok.Data;
import uno.rocc.common.constant.RespConstant;

@Data
@Builder
public class Result {

    private Integer code;
    private String msg;
    private Object data;

    public static Result success() {
        return Result.builder()
                .code(200)
                .msg(RespConstant.SUCCESS)
                .build();
    }

    public static Result success(Integer code, String msg) {
        return Result.builder()
                .code(code)
                .msg(msg)
                .build();
    }

    public static Result success(Object data) {
        return Result.builder()
                .code(200)
                .msg(RespConstant.SUCCESS)
                .data(data)
                .build();
    }

    public static Result fail() {
        return Result.builder()
                .code(500)
                .msg(RespConstant.FAIL)
                .build();
    }

    public static Result fail(Integer code, String msg) {
        return Result.builder()
                .code(code)
                .msg(msg)
                .build();
    }
}
